package com.keai.service;


import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.keai.dao.LogDao;
import com.keai.entity.PageResult;
import com.keai.entity.QueryPageBean;
import com.keai.pojo.LogMessage;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class LogServiceimpl implements LogService {
    @Autowired
    LogDao logDao;


    @Override
    public void addLog(LogMessage logMessage) {
        UserServiceImpl userService=new UserServiceImpl();
        String username = userService.getUsername();
        logMessage.setUser(username);
        logDao.add(logMessage);
    }

    @Override
    public PageResult findLog(QueryPageBean queryPageBean,String T1,String T2) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        System.out.println(queryPageBean.getQueryString()+"/"+T1+"/"+T2);
        Page<LogMessage>page=logDao.findLog(queryPageBean.getQueryString(),T1,T2);

        return new PageResult(page.getTotal(),page);
    }
}
